<div class="amp-content">
  <h3 class="amp-header"><?php echo $action_title; ?></h3>

  <form action="" method="post" enctype="multipart/form-data" class="amp-container">
    <?php while ($obj = $data->next()) { ?>
    <div class="amp-content">

      <?php
      $elements->reset();

      while ($element = $elements->next()) {
        echo $element->render($obj, $action);
      }
      ?>

      <div style="clear:both;"></div>

      <div id="tabs" style="display: none;"><ul></ul></div>

      <nav class="amp-toolbar-container">
        <ul class="amp-toolbar">
          <?php if ($obj->$pk) { ?>
          <li class="amp-toolbar-item"><a href="<?php echo Simplify::response()->makeUrl(Simplify::request()->route(), array('action' => 'delete', $pk => $obj->$pk)) ?>"
            onclick="return confirm('Confirma a remoção deste registro?');"><?php echo $this->icon->show('remove') ?></a></li>
          <?php } ?>
        </ul>

        <div style="clear:both;"></div>
      </nav>
    </div>
    <?php } ?>

    <nav class="amp-toolbar-container">
      <ul class="amp-toolbar">
        <li class="amp-toolbar-item"><input type="submit" value="Save"/></li>
      </ul>

      <div style="clear:both;"></div>
    </nav>
  </form>
</div>

<style>
.form_element_text {
  width:400px;
}

.form_element_textarea {
  width:600px;
  height:200px;
}
</style>

<script>
$(document).ready(function() {
  if ($('.form-fieldset').length) {
    $('.form-fieldset').each(function(index, item) {
      var label = $(item).find('legend').html();
      var content = $(item).find('.form-element-body').html();

      var li = '<li><a href="#tab-'+(index + 1)+'">'+label+'</a></li>';
      var div = '<div id="tab-'+(index + 1)+'">'+content+'</div>';

      $('#tabs ul').append(li);
      $('#tabs').append(div);
    }).remove();

    $('#tabs').tabs().show();
  }
});
</script>